import { Menu } from "@/api/interface/index";
import { PORT1 } from "@/api/config/servicePort";
import http from "@/api";

/**
 * @name 菜单编辑以及权限设置
 */

//全部菜单列表
export const getAllMenuListApi = (params: FormData) => {
  return http.get<Menu.MenuOptions[]>(PORT1+`/sys/menu/list-all`, params, { cancel: false });
};

//菜单累计访问
export const getAllMenuVisitNum = (params: FormData) => {
  return http.get(PORT1+`/sys/menu/statistics`, params, { cancel: false });
};

//新建菜单
export const addMenuListApi = (params: FormData) => {
  return http.post(PORT1+`/sys/menu/save`, params, { cancel: true });
};

//删除菜单
export const deleteMenuListApi = (id:string) => {
  return http.get(PORT1+`/sys/menu/delete?id=${id}`, { cancel: true });
};

//菜单收藏/取消收藏
export const collectMenuApi = (params: FormData) => {
  return http.post<Menu.collect>(PORT1+`/sys/menu/collect`, params, { cancel: false });
};

//公共设置存取
export const saveUserConfig = (params) => {
  return http.post<Menu.collect>(PORT1+`/api/save-user-config`, params, { cancel: false });
};

export const getGroupingList = (params) => {
  return http.get<Menu.collect>(PORT1+`/sys/menu/get-tag-list`, params, { cancel: false });
};